home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c,comp.graphics.algorithms,rec.games.programmer
- Subject: Re: Speed question here...
- Date: 20 Feb 1996 14:15:28 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4gdh60INN9l8@keats.ugrad.cs.ubc.ca>
- References: <4ftluh$1gkv@hearst.cac.psu.edu> <4fvjqnINN84p@keats.ugrad.cs.ubc.ca> <danpop.824472979@rscernix>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <danpop.824472979@rscernix>, Dan Pop <danpop@mail.cern.ch> wrote:
- >In <4fvjqnINN84p@keats.ugrad.cs.ubc.ca> c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
- >
- >>In article <4ftluh$1gkv@hearst.cac.psu.edu>,
- >>William Koscho <koscho@wjk130.rh.psu.edu> wrote:
- >>>I was curious as to how fast something like the
- >>>following would execute:
- >>
- >>I don't know? How fast can your compiler tell you that the program can't be
- >>compiled?
- >>
- >>> int x;
- >>> node *ptr; ptr in linked list
- >>>
- >>> for ( ptr = first_node; ptr != NULL; ptr = ptr.next ) {
- >>
- >>You don't dereference pointers by doing ptr.field. You use *(ptr).field, or,
- >
- >You misspelled (*ptr).field. *(ptr).field is the same as *ptr.field and
- >both are illegal because the dot operator has higher precedence.
-
- Oops. (Moves vi cursor over '*', hits 'xp') You _have_ to write (*ptr).field
- (rare!) to mean ptr->field, _or_ *(*ptr)->field, to dereference member "field",
- assuming it's a pointer to non-void.
-
- It's interesting that *(ptr).field construct even _looks_ wrong, like
- something is fishy. The parentheses obviously don't buy you anything since
- they don't group any symbols, which is far from what I intended. I apologize
- if I confused anyone.
- --
-
-